import requests

# 单张图片

# url
imageUrl = 'http://p1.music.126.net/gAxvLALYYiHCzNIzAsFdjg==/109951169715547644.jpg?imageView&quality=89'

# 发送请求
imageResp = requests.get(imageUrl)

# 保存图片  -二进制保存
with open("../file/image.jpg", "wb") as m:
    m.write(imageResp.content)
    print("图片爬取完成....")

# 单首歌曲
musicUrl = 'https://m801.music.126.net/20240624110309/4acf081f896cc6703a2f374186bfda01/jdyyaac/obj/w5rDlsOJwrLDjj7CmsOj/44025964441/8bab/d931/c011/906b3abeab0481367b8a76fb4abb2ce7.m4a'

# 构建请求头
header = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36'
}

# 发送请求
musicRes = requests.get(musicUrl, headers=header)

# 保存响应
with open('../file/music.mp3', 'wb') as mu:
    mu.write(musicRes.content)
    print("music爬取完成....")

# mv

mvUrl = 'https://vodkgeyttp8.vod.126.net/cloudmusic/f17a/core/6f01/b098abbf24d99ea0eccea88124d64319.mp4?wsSecret=3150a98d7a7d6ca54f944c9f5aabacc9&wsTime=1719196956'

header = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36'
}

mvRes = requests.get(mvUrl, headers=header)

with open('../file/mv.mp4', 'wb') as mv:
    mv.write(mvRes.content)
    print("mv爬取完成....")
